<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>

<head>
<title>Spring MVC AMS Application</title>
<c:import url="include.jsp"></c:import>
</head>

<body>
	<div class="header" onclick="javascript:location.href='/springmvc'">
		<h1><fmt:message key="wellcome"/></h1>
	</div>
	<div style="float: left; margin-left: 50px">
		<c:import url="left_menu.jsp"></c:import>
	</div>
	<div id="container">
		<form:form commandName="newAssetType" id="reg" action="/springmvc/assettype">
			<h2>Manage Asset Type</h2>
			<table>
				<tbody>
					<tr>
						<td><form:label path="code">Asset Type Code:</form:label></td>
						<td><form:input path="code" /></td>
						<td><form:errors class="invalid" path="code" /></td>
					</tr>
					<tr>
						<td><form:label path="name">Asset Type Name:</form:label></td>
						<td><form:input path="name" /></td>
						<td><form:errors class="invalid" path="name" /></td>
					</tr>
					<tr>
						<td><form:label path="parentAssetType">Asset Type Parent:</form:label>
						<td><form:input path="parentAssetType" /></td>
						<td><form:errors class="invalid" path="parentAssetType" /></td>
					</tr>
				</tbody>
			</table>
			<table>
				<tr>
					<td><input type="submit" value="Add" class="register" name="sb" /></td>
				</tr>
			</table>
		</form:form>
		
	<!-- <form:form id="sch" action="/springmvc/assettype/search">
			Search name: <input type="text" name="name"/>
			<input type="submit" value="Search" name="sb"/>
		</form:form> -->	
		
		<c:choose>
			<c:when test="${assetTypes.size()==0}">
				<em>No Asset Types.</em>
			</c:when>
			<c:otherwise>
				<h2>List Asset Type</h2>
				<table class="table table-striped">
					<thead>
						<tr>
							<th>Asset Type Code</th>
							<th>Asset Type Name</th>
							<th>Asset Type Parent</th>
							<th>Actions</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${assetTypes}" var="assetType">
							<tr>
								<td><a href="<c:url value="/view/${assetType.id}"/>">${assetType.code}</a></td>
								<td>${assetType.name}</td>
								<td>${assetType.parentAssetType}</td>
								<td><a href="<c:url value="/assettype/view/${assetType.id}"/>">View</a>
									/ <a href="<c:url value="/assettype/edit/${assetType.id}"/>">Edit</a>
									/ <a href="<c:url value="/assettype/delete/${assetType.id}"/>">Delete</a>
								</td>
						</c:forEach>
					</tbody>
				</table>
			</c:otherwise>
		</c:choose>
	</div>

	<div id="footer">
		<p>
			Footer page.<br />
		</p>

	</div>
</body>
</html>
